//
//  FeedBackModel.m
//  SoupApp
//
//  Created by pro1 on 2018/11/20.
//  Copyright © 2018 pro2. All rights reserved.
//

#import "FeedBackModel.h"
//#import "DatabaseManager.h"

@implementation FeedBackModel

- (void)toCalculateCellHeight{
    self.cellHeight = 6.0;
    if (!self.content) {
        return;
    }
    self.cellHeight += 106;
    self.contentSize = [self stringSzieWith:[UIFont fontWithName:@"PingFangSC-Medium" size:14] andWidth:SCREEN_WIDTH - 131 andText:self.content];
    self.cellHeight += self.contentSize.height;
}

- (CGSize)stringSzieWith:(UIFont *)font andWidth:(CGFloat)width andText:(NSString *)str{
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
    paraStyle.lineSpacing = 3.0;
    paraStyle.hyphenationFactor = 1.0;
    paraStyle.firstLineHeadIndent = 0.0;
    paraStyle.paragraphSpacingBefore = 0.0;
    paraStyle.headIndent = 0;
    paraStyle.tailIndent = 0;
    NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle,NSKernAttributeName:@1.0f};
    CGRect sizeToFit = [str boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:dic context:nil];
    return sizeToFit.size;
}

@end
